#include <machine/asmdefs.h>

ASM_HEADER

FNDEFN_BEGIN(cck_opt_asm)

T0029C8F0:
	lrr		%vr0,%r8,0
	lr		%vr4,%r10,0
	lr		%vr5,%r11,0
	lr		%vr6,%r10,32    ||	rfft0s		%vr1,%vr0,%vr4
	lr		%vr7,%r11,32	||	rfft0s		%vr2,%vr0,%vr5
	lr		%vr4,%r10,64	||	rfft1s		%vr0,%vr1,%vr6
	lr		%vr5,%r11,64	||      rfft1s		%vr3,%vr1,%vr7
        rfft2s		%vr1,%vr0,%vr4
	str		%vr1,%r9,0      ||	rfft2s		%vr0,%vr0,%vr5
	str		%vr0,%r9,32     ||	rfft2s		%vr1,%vr3,%vr4
	str		%vr1,%r9,64     ||	rfft2s		%vr0,%vr3,%vr5
	str		%vr0,%r9,96     ||	rfft1s		%vr0,%vr2,%vr6
        rfft1s		%vr3,%vr2,%vr7
        rfft2s		%vr1,%vr0,%vr4
	str		%vr1,%r9,128     ||	rfft2s		%vr0,%vr0,%vr5
	str		%vr0,%r9,160     ||	rfft2s		%vr1,%vr3,%vr4
	str		%vr1,%r9,192     ||	rfft2s		%vr0,%vr3,%vr5
	str		%vr0,%r9,224     ||	ji		%jt0,8

FNDEFN_END(cck_opt_asm)


FNDEFN_BEGIN(cck_opt_total_asm)

	lrr		%vr0,%r8,0      ||      lir		%r15,0
	lr		%vr4,%r9,0      ||	ctsr		%r15,0x45   # set mpos
	lr		%vr5,%r9,96     ||	ctsr		%r15,0x44   # set mcount
	lr		%vr6,%r9,32     ||	rfft0s		%vr1,%vr0,%vr4
	lr		%vr7,%r9,128	||	rfft0s		%vr2,%vr0,%vr5
	lr		%vr4,%r9,64	||	rfft1s		%vr0,%vr1,%vr6
	lr		%vr5,%r9,160	||      rfft1s		%vr3,%vr1,%vr7
        rfft2s		%vr1,%vr0,%vr4  ||	ctsr		%r15,75     # set ac3
	rfft2s		%vr0,%vr0,%vr5  ||	ctsr		%r15,67     # set mr3
	rmuls		%vr1,%vr1,%vr1  ||      str             %vr1,%r14,0
	rmuls		%vr0,%vr0,%vr0  ||      str             %vr0,%r14,32
	rmsumjs		%vr0,%vr1,0,%mr3
	rsearchmax	%ac3,%vr0
	rfft2s		%vr1,%vr3,%vr4
	rfft2s		%vr0,%vr3,%vr5
	rmuls		%vr1,%vr1,%vr1  ||      str             %vr1,%r14,64
	rmuls		%vr0,%vr0,%vr0  ||      str             %vr0,%r14,96
	rmsumjs		%vr0,%vr1,0,%mr3
	rsearchmax	%ac3,%vr0
	rfft1s		%vr0,%vr2,%vr6
        rfft1s		%vr3,%vr2,%vr7
        rfft2s		%vr1,%vr0,%vr4
	rfft2s		%vr0,%vr0,%vr5
	rmuls		%vr1,%vr1,%vr1  ||      str             %vr1,%r14,128
	rmuls		%vr0,%vr0,%vr0  ||      str             %vr0,%r14,160
	rmsumjs		%vr0,%vr1,0,%mr3
	rsearchmax	%ac3,%vr0
	rfft2s		%vr1,%vr3,%vr4
	rfft2s		%vr0,%vr3,%vr5
	rmuls		%vr1,%vr1,%vr1  ||      str             %vr1,%r14,192
	rmuls		%vr0,%vr0,%vr0  ||      str             %vr0,%r14,224
	rmsumjs		%vr0,%vr1,0,%mr3
	rsearchmax	%ac3,%vr0

        /* get mpos, use to find max position, max I, max Q */
	cfsr		%r15,0x45
	sli		%r15,%r15,2
	add		%r8,%r10,%r15
	lw		%r8,%r8,0       ||      add             %r9,%r14,%r15
        stw             %r8,%r11,0

        luh             %r10,%r9,2
        stuh            %r10,%r12,0
        luh             %r10,%r9,0
        stuh            %r10,%r13,0

        ji		%jt0,8


FNDEFN_END(cck_opt_total_asm)



